import request from '../utils/request'

export const homeRequest = {
    banner() {
        return request({
            url: '/api/v1/index/banners',
            method: 'GET'
        })
    },
    tabs() {
        return request({
            url: '/api/v1/index/card-themes',
            method: 'GET'
        })
    },
    content({themeId, pageNo, pageSize}) {
        return request({
            url: `/api/v1/cards/themes/${themeId}`,
            method: 'GET',
            data: {
                pageNo,
                pageSize
            }
        })

    }
}

export const cardRequest = {
    save(data) {
        return request({
            url: '/api/v1/card/save',
            method: 'POST',
            data
        })
    },
    desginList() {
        return request({
            url: '/api/v1/card/my-design',
            method: 'POST'
        })
    },
    historyList({ pageNo, pageSize }) {
        return request({
            url: '/api/v1/card/my-print-records',
            method: 'GET',
            data: {
                pageNo, pageSize
            }
        })
    },
    read(cardId) {
        return request({
            url: `/api/v1/card/detail/${cardId}`,
            method: 'GET'
        })
    },
    print({ cardId, shopId }) {
        return request({
            url: `/api/v1/card/print`,
            method: 'POST',
            data: {
                cardId, shopId
            }
        })
    },
    printTemplate({ cardId, shopId }) {
        return request({
            url: `/api/v1/card/template/print`,
            method: 'POST',
            data: {
                templateCardId: cardId, shopId
            }
        })
    },
    testDraft() {
        return request({
            url: `/api/v1/card/is-have-draft`,
            method: 'GET'
        })
    }
}

export const searchRequest = {
    history() {
        return request({
            url: '/api/v1/cards/recent/search',
            method: 'GET',
        })
    },
    search(data) {
        return request({
            url: '/api/v1/cards/search',
            method: 'GET',
            data
        })
    }
}

// 店铺搜索
export const searchShop = (keyword) => {
    return request({
        url: '/api/v1/card/shop-search',
        method: 'POST',
        data: {
            keyword
        }
    })
}
// 获取用户信息
export const getUserInfo = () => {
    return request({
        url: '/api/v1/auth/userInfo',
        method: 'GET'
    })
}
// 获取协议
export const getSystemAgreement = () => {
    return request({
        url: '/api/v1/conf/user-agreement',
        method: 'GET'
    })
}
// 获取客服信息
export const getServiceConf = () => {
    return request({
        url: '/api/v1/conf/website-contact',
        method: 'GET'
    })
}
// 保存手机号
export const setPhone = (phone) => {
    return request({
        url: '/api/v1/auth/wx/phone',
        method: 'GET',
        data: {
            code: phone
        }
    })
}

/**
 * 上传图片
 */

export const getOSS = () => {
    return request({
        url: '/api/v1/oss/aliyunsts',
        method: 'GET'
    })
}
